home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
tex
/
fr_may92.zip
/
FR.ASM
< prev
next >
Wrap
Assembly Source File
|
1992-05-04
|
13KB
|
422 lines
; FR.ASM --- TSR source for frequency logger.
;
;make file with turbo asm and linker:
;tasm fr.asm,,nul,nul;
;tlink /t fr,,nul,;
;
; make file with masm, link, exe2bin:
; masm fr.asm,,nul,nul;
; link fr,,nul,;
; exe2bin fr.exe fr.com
; del fr.exe
;
;Purpose: Maintains last access date and time for all files opened
; by DOS call 3dh by logging the file name to file \freq.dat.
;
;Use: Start FR.COM. The file \FREQ.DAT will be created if it does not
; yet exist. File names are appended to the end of the file. The
; collection file can be deleted, examined, etc, at any time.
; The dump file name can be changed by a patch in debug: lots of
; space is provided. At present, the TSR cannot de-install itself
; but it does detect its own presence.
;
;Version: 17 Jan 1992 [prev: 1 December 1991]
;Authors: Grant B. Gustafson and Greg Conner.
; Other authors will be added here as contributions are made.
;email: gustafso@math.utah.edu, conner@math.utah.edu (Internet addresses)
;Copyright:
; The source code is jointly owned by the authors. It may be used
; for educational purposes without limitation. Modified versions
; of the sources are considered private copies and should bear
; the new authors names but not the present authors names.
;Responsibility:
; This computer program is used at your own risk. If you use it,
; then you assume responsibility for anything that happens as a
; result of the program operation, including but not limited to
; programming errors, faulty operation, file system destruction.
; The authors are not responsible.
;
Cseg segment public para
assume cs:Cseg, ds:nothing, es:nothing, ss:nothing
org 080H
cmdline label byte ;pointer to command line
org 100H
comentry: jmp init
;previous interrupt handlers
even
dos_int label dword
old21 dw 2 dup (?) ;old int21 vector
;***********************************************************************
;interrupt handler for int21
newint21 proc near
assume ds:nothing
pushf ;save flags
push si
mov si,offset fn ;are we to ignore updates?
cmp byte ptr cs:[si],1
pop si
jne ex21
cmp ax,'fr' ;check for install twice
jne ex20
popf ;tried to install twice
xor ax,ax ;clear flags
mov ax,'co' ;return code for install
iret ;return from interrupt
ex20:
cmp ah,3dh
jne ex21
call update ;update dir entry
ex21: popf
jmp (dos_int) ;transfer to previous int21 vector
newint21 endp
;******************************************************************************
;resident data section follows
;******************************************************************************
even
;temporary stack used by interrupt handler
newss dw 0 ;segment of our temporary stack
newsp dw 0 ;initial stack pointer
;information saved about the calling program
oldss dw ? ;stack segment
oldsp dw ? ;stack pointer
;***********************************************************************
;
update proc near
assume ds:nothing
;save current stack
mov oldss,ss
mov oldsp,sp
;switch to our stack
cli
mov ss,newss
mov sp,newsp
sti
;store registers
push ax
push bx
push cx
push si
push di
push es
push dx
push ds
call mungfile ;full path name needed
call openfile ;open existent file c:\FREQ.DAT
cmp ax,0 ;returns 0 if file not open
jz quit
call seekend ;seek to end of file
call writefile ;write string to file
call closefile ;close c:\FREQ.DAT
quit:
;restore registers
pop ds
pop dx
pop es
pop di
pop si
pop cx
pop bx
pop ax
;restore stack
cli
mov ss,oldss
mov sp,oldsp
sti
ret
update endp
mungfile proc near
;copy file name, fix path name to give disk and directory
assume ds:nothing
mov ax,ds
mov es,ax
mov di,dx ;es:di=source string
mov ax,cs
mov ds,ax
mov si,offset path ;ds:si=dest string
; check for ':' at position 2 of string
mov al,byte ptr es:[di]
cmp al,0
je loop1exit
inc di
mov ah,byte ptr es:[di]
dec di
cmp ah,':' ;drive spec present?
jne loop1exit ;not found
inc di
inc di
jmp loop1success
loop1exit: ;no ':' found
; look up the default drive number
mov ah,19h
int 21h
add al,'A' ;convert to letter
loop1success: ;found ':'
mov bl,al ;save drive letter
mov byte ptr ds:[si],al
inc si
mov byte ptr ds:[si],':'
inc si
push di
; check for '/' or '\' in source string
mov al,byte ptr es:[di]
cmp al,'\'
je loop2success
cmp al,'/'
je loop2success
getdefault:
;can't find delimiter, so look up default directory
mov byte ptr ds:[si],'\' ;need delimiter
inc si
mov dl,bl ;bl=drive letter
sub dl,'A'
add dl,1
; mov ds,buffer segment
; mov si,buffer offset
push si
mov ah,47h ;get current dir name
int 21h
pop si
jnc loop3
dec si
mov byte ptr ds:[si],0
loop3:
cmp byte ptr ds:[si],0 ;advance past default
je loop2success ;dir name
inc si
jmp loop3
loop2success:
pop di
dec si
cmp byte ptr ds:[si],'\' ;delimiter already?
je loop35 ;then skip it
inc si
loop35:
mov al,byte ptr es:[di]
cmp al,'\' ;start with '\'?
je loop4
cmp al,'/' ;start with '/'?
je loop4
mov byte ptr ds:[si],'\' ;no, then put in delimiter
inc si ;(but not two consecutive)
loop4:
mov al,byte ptr es:[di] ;get source byte
mov byte ptr ds:[si],al ;put dest byte
cmp al,0
je loop5
inc si
inc di
jmp loop4 ;loop until copied
loop5:
mov byte ptr ds:[si],13 ;put dest byte
inc si
mov byte ptr ds:[si],10 ;put dest byte
inc si
mov byte ptr ds:[si],0 ;put dest byte
ret
mungfile endp
openfile proc near
; FILEN=filename
; Open file. Create it if missing.
assume ds:nothing
; open the file
mov ax,cs
mov ds,ax